<?php

Raise::load('core.RaiseAppPackageLoader');

/**
 * TestCoreRaiseAppPackageLoader class
 * Testing unit of 'phpraise/core/RaiseAppPackageLoader.php'
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseAppPackageLoader extends RaiseTest {

    public static function testClass() {
        self::assertClassExists('RaiseAppPackageLoader');
        self::assertClassExtends('RaiseAppPackageLoader', 'RaiseObject');
    }

    public static function testLoadingPackage(){
        self::assertStrictEqual(RaiseTemplate::loadCount(), 0);
        $settings = new RaiseSettings();
        $settings->set('phpRaise', 'appRoot', 'mocks');
        $settings->set('phpRaise', 'timezone', 'GMT');
        $app = new RaiseApplication($settings);
        $loader = new RaiseAppPackageLoader($app);
        self::assertFalse(class_exists('mockPackageContent'));
        $loader->loadPackage('MockPackage');
        self::assertClassExists('mockPackageContent');

        // loadTemplate is called within RaiseApplication
        self::assertStrictEqual(RaiseTemplate::loadCount(), 1);
    }

}
